
const  id = JSON.parse(localStorage.getItem('id'))
const  address = JSON.parse(localStorage.getItem('address'))
const  city = JSON.parse(localStorage.getItem('city'))
let state = {
  id: id,
  address: address,
  city: city
}

const getters = {
  getCurrentAddressId(state) {
    let result = JSON.parse(localStorage.getItem('id'));
    if (result) {
      state.id = result
    }
    return state.id;
  },
  getAddress(state) {
    let result = JSON.parse(localStorage.getItem('address'));
    if (result) {
      state.address = result
    }
    return state.address;
  },
  getCurrentCit(state) {
    let result = JSON.parse(localStorage.getItem('city'));
    if (result) {
      state.city = result
    }
    return state.city;
  },

}

const mutations = {
  saveCurrentAddressId(state, data) {
    state.id = data;
    localStorage.setItem('id',JSON.stringify(state.id))
  },
  deleteId(state){
    state.id = null;
    localStorage.removeItem('id')
  },
  saveAddress(state, data) {
    state.address = data;
    localStorage.setItem('address',JSON.stringify(state.address))
  },
  deleteAddress(state){
    state.address = null;
    localStorage.removeItem('address')
  },
  deleteCurrentCit(state){
    state.city = null;
    localStorage.removeItem('city')
  },
  saveCurrentCity(state, data) {
    state.city = data;
    localStorage.setItem('city',JSON.stringify(state.city))
  },

}

export default {
  state,
  getters,
  mutations
}